<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/list.css">
    <title><spring:message code="bigcargo_style_list" /></title>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/bootstrap_table/bootstrap-table.css" rel="stylesheet">
    <link href="${ctxStatic}/bootstrap_table/bootstrap-table-reorder-rows.css" rel="stylesheet">
    <script type="text/javascript" src="${ctxStatic}/bootstrap_table/jquery.tablednd.js"></script>
    <script src="${ctxStatic}/bootstrap_table/bootstrap-table.js"></script>
    <script src="${ctxStatic}/bootstrap_table/bootstrap-table-reorder-rows.js"></script>
    <script type="text/javascript">
        var trLength;
        $(function () {
        	$("select").select2();
            $("#tableId").bootstrapTable({
                reorderableRows: true,
                onReorderRowsDrag: function (table, row) {
                    console.log(1)
                },
                onReorderRowsDrop: function (table, row) {
                    console.log(2)
                },
                onReorderRow: function (newData) {
                    console.log(3)
                }
            });
            trLength = $("#tableId").find("tr").length;

        });
        //质检项目画面 
        function selectItem(){
        	popup("1000px","680px","${ctx}/check/quality/selectQualityItem");
        }
        
        /* 删除 项目  */
		function deleteCurrentRow(obj){ 
		 	if (confirm("确定删除该质检项目吗？")) {
				var tr=obj.parentNode.parentNode;  
				$(tr).remove();
			}
		}
        
        // 查询质检项目 
        function searchItem(){
        	window.location.href = "${ctx}/check/quality/?operatingId="+$("#operatingId").val();
        }
        
        // 保存数据 
        function saveForm(){
        	$("#activity_pane").showLoading();
        	setIndex();
        	var params = $("#searchForm").serialize();
        	$.post("${ctx}/check/quality/saveForm",params,function(result){
        		$("#activity_pane").hideLoading();
        		tipParent(result.message);
        		searchItem();
        	})
        }
        //
        var tempIndex;
        /* 设置下标  */
        function setIndex(){
            var reg=/tempIndex/g;
    		var trLength = $("#tableId tr").length-1;
    		if (trLength >= 1) {
    			for (var i = 0; i < trLength; i++) {
                        var itemTr = $("#tableId tr").eq(i+1);
    					$(itemTr).html($(itemTr).html().replace(reg,i));
    			}
    		}
    		
    	}
        
     // 缓存数据 
        function refreshHtml(){
        	setIndex();
        	var params = $("#searchForm").serialize();
        	$.post("${ctx}/check/quality/sessionList",params,function(result){
	        	window.location.href = "${ctx}/check/quality/newList?operatingId="+$("#operatingId").val();
        	})
        }
    </script>
</head>
<body>
	<form id="searchForm">
    <div class="listArea" id="activity_pane">
	    <div class="listBg">
            <div class="searchArea clearfix">
                <div class="searchArea clearfix" style="border:2px solid #13031e33;width:1085px;position:relative;left:10px;top:10px;height:50px">
                <div class="items clearfix">

                    <div class="col-50 clearfix haveToBox">
                        <!-- 工序列表 -->
                        <p class="tit" style="width:100px;">
                            <spring:message code="project_procedure"/>
                        </p>
                        <select style="width:230px" name="operatingId" id="operatingId" onchange="searchItem();">
                            <c:forEach items="${checkQualityEntity.operatingList}" var="operatingList" varStatus="status">
	                            <c:if test="${operatingList.operatingId == 34 || operatingList.operatingId == 35 || operatingList.operatingId == 36 || operatingList.operatingId == 37}">
	                            	<option value="${operatingList.operatingId}" <c:if test="${operatingList.operatingId eq checkQualityEntity.operatingId}">selected</c:if>>${operatingList.valueNameCn}</option>
	                            </c:if>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="col-50 clearfix haveToBox" >
                        <button style="position:absolute;right:140px" type="button" onclick="saveForm()"><spring:message code="common_save"/></button>
                        <button style="position:absolute;right:1px" type="button" onclick="selectItem()">添加/设置 质检项目</button>
                    </div>
                </div>
            </div>
            </div>
    		<div class="tableArea" style="padding: 20px 10px 5px 20px;">
                <div class="tableScrollSm" style="overflow: auto;width: 1085px;height: 710px;padding-top: 0;">
                    <table cellpadding="0" class="bordered" id="tableId" title="拖动行可以进行排序">
                        <thead>
                            <tr>
                                <th>操作</th>
                                <th>质检项目名称</th>
                                <th>项目Code</th>
		                        <th>项目Value</th>
                            </tr>
                        </thead>
                        <c:forEach items="${checkQualityEntity.qcList}" var="item" varStatus="status">
						    <tr>
						    	<td><img src='${ctxStatic}/images/btn-sc.png' class="tab-cz" onclick='deleteCurrentRow(this)'></td>
						    	<td>${item.qcItem }
						    		<input type="hidden" class="qcId" name="qcList[tempIndex].qcId" value="${item.qcId }"/>
						    		<input type="hidden" class="operatingId" name="qcList[tempIndex].operatingId" value="${item.operatingId }"/>
						    		<input type="hidden" class="qcItem" name="qcList[tempIndex].qcItem" value="${item.qcItem }"/>
						    		<input type="hidden" class="qcItemCd" name="qcList[tempIndex].qcItemCd" value="${item.qcItemCd }"/>
						    		<input type="hidden" class="qcItemValue" name="qcList[tempIndex].qcItemValue" value="${item.qcItemValue }"/>
						    	</td>
						    	<td>${item.qcItemCd }</td>
						    	<td>${item.qcItemValue }</td>
						    </tr>
                        </c:forEach>
                	</table>
            	</div>
        	</div>
        	</div>
    </form>
</body>
</html>
